<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        #banner{
            width: 100%;
            height: 200px;
            border:solid 1px #666;
        }

        #banner2{
            width: 100%;
            height: 200px;
            border:solid 1px rgb(114, 26, 26);
        }

        #c{
            color: #4969d3;
        }
    </style>
</head>
<body>
    <div id="banner">

    </div>

    <div id="banner2">

    </div>

    <script>
        //获取元素
        let banner = document.querySelector('#banner');
        let banner2 = document.querySelector('#banner2');

        //绑定事件
        banner.ontouchstart = function(){
            //改变 div 的背景颜色
            this.style.background = 'rgb(201, 72, 72)';
            console.log('你触摸了我');
            this.start = Date.now();
        }

        banner.onclick = function(){
            console.log('你点击了我');
            this.end = Date.now();
            console.log('时间间隔为' + (this.end - this.start))
        }

        //touchmove 事件
        banner.addEventListener('touchmove', function(){
            this.style.background = '#c9bc48';
            console.log(111);
        });

        //touchend
        banner.addEventListener('touchend', function(){
            this.style.background = '#4969d3'
        });

        //touchcancel 
        banner.addEventListener('touchcancel', function(){
            console.log('触摸被打断啦!!!');
        });


        banner2.addEventListener('touchmove', function(){
            this.style.background = 'black';
        })

        setTimeout(() => {
            // alert(123);
        }, 3000)

    </script>
</body>
</html>